
module.exports = function ($scope, $state, $stateParams,$resource,$modal,iteminfo,$modalInstance,FileUploader, type) {
  console.log(iteminfo);
  $scope.item = iteminfo;
  $scope.type = type;
  $scope.rejectArr = [];
  console.log(type + $scope.type);
  var level = '';
  if (type == '0') { // 区县规划处
    level = '2';
  } else if (type == '1') { // 市级复核
    level = '2';
  }  else if (type == '3') { // 区县责任处室
    level = '1';
  }
  // 公告类型
  $scope.typeFileArr = [
      {name:'王者类型',value:'1', id : '1'},
      {name:'青铜',value:'2', id : '2'},
      {name:'白银',value:'3', id : '3'},
      {name:'王者类型1',value:'4', id : '4'},
      {name:'青铜1',value:'5', id : '5'},
      {name:'白银1',value:'6', id : '6'},
      {name:'王者类型2',value:'7', id : '7'},
      {name:'青铜2',value:'8', id : '8'},
      {name:'白银2',value:'9', id : '9'}        
  ]
  $scope.rejectArr = [];
  // 详情
  $scope.getInfo = function(){
      $resource('/api/as/ggc/reviewPlanning/findInfo', {}, {}).save({'project_code':iteminfo.project_code}, function(res){			              
          if(res.errcode === 0 || res.errcode === 10003){
              console.log(res);
              $scope.a = res.data;
              if($scope.a.city_project=='0'){
                  $scope.a.city_project='区县项目'
              } else if($scope.a.city_project=='1'){
                  $scope.a.city_project='市本级项目'
              } 
              if($scope.a.project_build=='0'){
                  $scope.a.project_build='建设类'
              } else if($scope.a.project_build=='1'){
                  $scope.a.project_build='非建设类'
              }
              if($scope.a.project_level=='0'){
                  $scope.a.project_level='国家'
              } else if($scope.a.project_level=='1'){
                  $scope.a.project_level='省'
              } else if($scope.a.project_level=='2'){
                  $scope.a.project_level='市'
              } 
              $scope.getProjecttType($scope.a.project_type);
              $scope.material = JSON.parse($scope.a.project_file);
              if($scope.material.aa){
                $scope.array1 = $scope.material.aa;
              } else {
                $scope.array1 = undefined;
              }
              if($scope.material.bb){
                $scope.array2 = $scope.material.bb;
              } else {
                $scope.array2 = undefined;
              }
              $scope.array3 = $scope.material.cc;
              $scope.array4 = $scope.material.dd;
              $scope.array5 = $scope.material.ee;
              $scope.array6 = $scope.material.ff;
              $scope.array7 = $scope.material.gg;
              $scope.array8 = $scope.material.hh;
              $scope.array9 = $scope.material.ii;

          }else{
              alert(res.errmsg);
          }
      });
  }
  $scope.getInfo();
  $scope.array = [];
  $scope.getCLInfo = function (){
      $resource('/api/ac/ggc/reviewCompanyRejectService/findCompanyRejectList', {}, {}).save({'project_code':iteminfo.project_code, 'type' : level}, function(res){			              
          if(res.errcode === 0 || res.errcode === 10003){
              console.log('材料详情');
              console.log(res);
              console.log(iteminfo.project_build);
              $scope.rejectArr = res.data;
              console.log($scope.rejectArr[3].reject); 
          }else{
              alert(res.errmsg);
          }
      });
  }
  $scope.getCLInfo();
  $scope.getProjecttType = function(project_type){
      $scope.typeFileArr.forEach(element => {
        if(project_type == element.value){
          $scope.a.project_type = element.name;
        }
      });
  }
  // $scope.del=function(index){
  //     $scope.array.splice(index,1);
  //     $scope.a.project_file=$scope.array.join(',');
  // }
  // $scope.image = function(){
  //     var para = $state.get('app.imageupload');
  //     //设置上传文件夹，以自己业务命名
  //     angular.extend(para, {
  //       resolve : {  
  //         'dir' : function(){
  //           return 't1';
  //         }
  //       } 
  //     })
  //     console.log(para);
  //     var modalInstance = $modal.open(para);
  //     modalInstance.opened.then(function() {// 模态窗口打开之后执行的函数  
  //       console.log('modal is opened');  
  //     });  
  //     modalInstance.result.then(function(result) {  
  //       console.log(result);  
  //       $scope.imagearr = JSON.stringify(result);
  //       // console.log(scope.imagearr);
  //       $scope.array = result;
  //                 $scope.a.project_file=$scope.array;
  //       // $scope.a.project_file = array[0];
  //       // console.log(scope.info.img);
  //       // form.result['templete_lock_data_json'] = JSON.stringify(result.lock);
  //       // form.result['templete_check_data_json'] = result.unlock;

  //     }, function(reason) {  
  //       console.log(reason);// 点击空白区域，总会输出backdrop  
  //       // click，点击取消，则会暑促cancel  
  //       $log.info('Modal dismissed at: ' + new Date());  
  //     }); 
  // };
  // // 单条通过
  // $scope.singlePass = function (str){
  //     console.log(str);
  //     var dic = {'img' : str, 'state' : '1'};
  //     $scope.rejectArr.push(dic);
  //     console.log($scope.rejectArr);
  //     var box1=document.getElementById(str);
  //     box1.style.display = '';
  //     console.log(box1);
  //     var box2=document.getElementById(str + '1');
  //     box2.style.display = 'none';
  //     toaster.success({title:"",body:'通过成功'});
  // }  
  // // 单条驳回
  // $scope.singleReject = function (str){
  //     console.log(str);
  //     var box1=document.getElementById(str);
  //     box1.style.display = 'none';
  //     console.log(box1);
  //     var box2=document.getElementById(str + '1');
  //     box2.style.display = '';
  //     var modalInstance = $modal.open({
  //         template: require('../views/singel_back_reason.html'),
  //         controller: 'singel_back_reason',
  //         size: 'xs',
  //         resolve: {
  //             str: function () {
  //                 return str;
  //             },
  //         }
  //     });
  //     modalInstance.result.then(function (showResult) {	
  //         console.log('带回来的驳回信息');
  //         console.log(showResult);
  //         $scope.rejectArr.push(showResult);
  //         console.log($scope.rejectArr);
  //     });  
  // }    
  // // 区县通过
  // $scope.pass= function () {   
  //   if ($scope.type == '0'){ // 区县规划处复核通过
  //       $scope.flag = 'ghcfhtg';
  //       var modalInstance = $modal.open({
  //         template: require('../views/passInfo.html'),
  //         controller: 'passInfo',
  //         size: 'xs',
  //         resolve: {
  //             iteminfo: function () {
  //                 return $scope.item;
  //             },
  //             'flag': function () {
  //                 return $scope.flag;
  //             },
  //         }
  //       });
  //       modalInstance.result.then(function (showResult) {	
  //         $modalInstance.close();
  //         $state.go('app.project_review');
  //       });  
  //   } else if(type == '1') { // 市级复核通过
  //     $scope.flag = 'sjfhtg';
  //       var modalInstance = $modal.open({
  //         template: require('../views/passInfo.html'),
  //         controller: 'passInfo',
  //         size: 'xs',
  //         resolve: {
  //             iteminfo: function () {
  //                 return $scope.item;
  //             },
  //             'flag': function () {
  //                 return $scope.flag;
  //             },
  //         }
  //       });
  //       modalInstance.result.then(function (showResult) {	
  //         $modalInstance.close();
  //         $state.go('app.project_review');
  //       }); 
  //   } else if (type == '3') { //区县责任处室复核通过
  //       $scope.flag = 'zrcsfhtg';
  //       var modalInstance = $modal.open({
  //         template: require('../views/passInfo.html'),
  //         controller: 'passInfo',
  //         size: 'xs',
  //         resolve: {
  //             iteminfo: function () {
  //                 return $scope.item;
  //             },
  //             'flag': function () {
  //                 return $scope.flag;
  //             },
  //         }
  //       });
  //       modalInstance.result.then(function (showResult) {	
  //         $modalInstance.close();
  //         $state.go('app.project_review');
  //       }); 
  //   }
  // }
  // // 驳回
  // $scope.againPass= function () { 
  //     if ($scope.type == '1'){
  //       $scope.flag = 'sjfhbh';
  //     } else if ($scope.type == '0'){
  //       $scope.flag = 'ghcfhbh';
  //     } else if ($scope.type == '3'){
  //       $scope.flag = 'zrcsfhbh';
  //     }
  //     var modalInstance = $modal.open({
  //         template: require('../views/reject_info.html'),
  //         controller: 'reject_info',
  //         size: 'xs',
  //         resolve: {
  //             iteminfo: function () {
  //                 return $scope.item;
  //             },
  //             'flag': function () {
  //                 return $scope.flag;
  //             },
  //             'type': function () {
  //                 return $scope.type;
  //             },
  //             'array': function () {
  //                 return $scope.rejectArr;
  //             },
  //         }
  //     });
  //     modalInstance.result.then(function (showResult) {	
  //       $modalInstance.close();
  //       $state.go('app.project_review');
  //     });  	
  // }
  // // 淘汰
  // $scope.eliminate= function () {  
  //     if ($scope.type == '1'){
  //       $scope.flag = 'sjfhtt';
  //     } else if ($scope.type == '0'){
  //       $scope.flag = 'ghcfhtt';
  //     } else if ($scope.type == '3'){
  //       $scope.flag = 'zrcsfhtt';
  //     } 
  //     var modalInstance = $modal.open({
  //         template: require('../views/reject_info.html'),
  //         controller: 'reject_info',
  //         size: 'xs',
  //         resolve: {
  //             iteminfo: function () {
  //                 return $scope.item;
  //             },
  //             'flag': function () {
  //                 return $scope.flag;
  //             },
  //             'type': function () {
  //                 return $scope.type;
  //             },
  //             'array': function () {
  //                 return $scope.rejectArr;
  //             }
  //         }
  //     });
  //     modalInstance.result.then(function (showResult) {	
  //         $modalInstance.close();
  //         $state.go('app.project_review');
  //     });  
  // }

  $scope.close = function(){
      $modalInstance.close();
  }
};
